#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

int a[10] = {1, 2, 3, 4};
int n = 4;

int main() {

    for (int i = 0; i < 24; i++) {
        copy(a, a + n, ostream_iterator<int>(cout, " "));
        cout << endl;
        next_permutation(a, a + n);
    }
    return 0;
}
